/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-03-23
*/
package com.rzico.article.entity;

import com.rzico.annotation.IgnoreSwaggerParameter;
import com.rzico.article.model.ArticleMeta;
import com.rzico.basics.entity.Member;
import com.rzico.core.entity.SysUser;
import lombok.Data;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * <pre>
 *   报名记录数据库对象
 * </pre>
 * @author Rzico Boot
 * @version 1.0
 */
@Data
@JsonIgnoreProperties(value = {"handler"})
@JsonInclude(JsonInclude.Include.NON_NULL)
@Table(name = "wx_enroll_order")
public class EnrollOrder{
    @Id
    @ApiModelProperty(value = "" )
    protected Long id;

    @ApiModelProperty(value = "创建日期" )
    protected java.util.Date createDate;

    @ApiModelProperty(value = "修改日期" )
    protected java.util.Date modifyDate;

    @ApiModelProperty(value = "订单编号" )
    protected String sn;

    @ApiModelProperty(value = "名称" )
    protected String title;

    @ApiModelProperty(value = "副标题" )
    protected String subTitle;

    @ApiModelProperty(value = "状态 {0:待付款,1:已付款,2:待退款,3:已退款}" )
    protected Integer paymentStatus;

    @ApiModelProperty(value = "订单状态 {0:待确认,1:已确认,2:已完成,3:已取消}" )
    protected Integer orderStatus;

    @ApiModelProperty(value = "手续费" )
    protected java.math.BigDecimal fee;

    @ApiModelProperty(value = "销售价" )
    protected java.math.BigDecimal price;

    @ApiModelProperty(value = "缩例图" )
    protected String thumbnail;

    @ApiModelProperty(value = "文章id" )
    protected Long articleId;

    @ApiModelProperty(value = "报名人" )
    protected Long memberId;

    @ApiModelProperty(value = "推广员" )
    protected Long promoterId;

    @ApiModelProperty(value = "是否分账" )
    protected Boolean isDistribution;

    @ApiModelProperty(value = "付款日期" )
    protected java.util.Date paymentDate;

    @ApiModelProperty(value = "结算日期" )
    protected java.util.Date settlingDate;

    @ApiModelProperty(value = "渠道来源")
    protected String scene;

    @ApiModelProperty(value = "优惠金额" )
    protected java.math.BigDecimal discount;

    @ApiModelProperty(value = "营销活动" )
    protected String promotion;


    @ApiModelProperty(value = "业绩奖1" )
    protected java.math.BigDecimal rebate1;

    @ApiModelProperty(value = "业绩奖2" )
    protected java.math.BigDecimal rebate2;

    @ApiModelProperty(value = "业绩奖3" )
    protected java.math.BigDecimal rebate3;

    @ApiModelProperty(value = "推广员1" )
    protected Long promoter1;

    @ApiModelProperty(value = "推广员2" )
    protected Long promoter2;

    @ApiModelProperty(value = "推广员3" )
    protected Long promoter3;

    @ApiModelProperty(value = "联系人" )
    protected String contact;

    @ApiModelProperty(value = "联系电话" )
    protected String phone;

    @ApiModelProperty(value = "微信号" )
    protected String userId;

    @JsonIgnore
    @ApiModelProperty(value = "是否删除" ,hidden = true )
    protected Boolean deleted;

    @ApiModelProperty(value = "所属企业" )
    protected Long enterpriseId;

    @JsonIgnore
    @ApiModelProperty(value = "创建者" ,hidden = true )
    protected String createBy;

    @JsonIgnore
    @ApiModelProperty(value = "更新者" ,hidden = true )
    protected String modifyBy;

    /**
     * 当前对象的量表信息
     */
    @JsonIgnore
    @IgnoreSwaggerParameter
    protected Article article;


    /**
     * 当前对象的买家信息
     */
    @JsonIgnore
    @IgnoreSwaggerParameter
    protected Member member;


    public String getNickName() {
        Member member = getMember();
        if (member!=null) {
            SysUser sysUser = member.getSysUser();
            if (sysUser!=null) {
                return sysUser.getNickname();
            }
        }
        return "";
    }

    public String getAvatar() {
        Member member = getMember();
        if (member!=null) {
            SysUser sysUser = member.getSysUser();
            if (sysUser!=null) {
                return sysUser.getAvatar();
            }
        }
        return "";
    }


    public ArticleMeta getArticleMeta() {
        Article article = getArticle();
        if (article!=null) {
            return article.getArticleMeta();
        } else {
            return null;
        }
    }


}
